package org.xm.moretriggercommands;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

public class ReloadCommand implements CommandExecutor {

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

        if (command.getName().equalsIgnoreCase("mtc")) {

            if (args.length == 0) {
                help(sender);
                return true;
            }
            if (args.length == 1 && args[0].equalsIgnoreCase("help")) {
                help(sender);
                return true;
            }

            // 处理重载命令
            if (args[0].equalsIgnoreCase("reload")) {
                if (sender.hasPermission("mtc.reload")) {
                    Main.getInstance().CreateConfig();
                    Main.getInstance().verify();
                    sender.sendMessage("§a[MoreTriggerCommands]: §c重载成功");
                } else {
                    sender.sendMessage("你都莫得权限，干哈呢？？？？？？？");
                }
                return true;
            }


        }
        return false;
        }
    public void help(CommandSender sender) {
        sender.sendMessage("");
        sender.sendMessage("§6===== §aMoreTriggerCommands 插件帮助 §6=====");
        sender.sendMessage("§e/mtc help §7- 查看插件帮助");
        sender.sendMessage("§e/mtc reload §7- 重载插件配置文件");
        sender.sendMessage("§6========================================");
        sender.sendMessage("");
    }
}